textbtree: Don't opencode realloc
authorMatthias Clasen <mclasen@redhat.com>
Sun, 4 Apr 2021 02:00:48 +0000 (22:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 4 Apr 2021 18:20:25 +0000 (14:20 -0400)
We can just use g_realloc here.

gtk/gtktextbtree.c

index 19189affc67a80a0e04dc640351e5ae0ced1221b..bfe628cf77f0a54783bbf7f8edb6f6e895360291 100644 (file)
@@ -6496,21 +6496,9 @@ inc_count (GtkTextTag *tag, int inc, TagInfo *tagInfoPtr)
 
   if (tagInfoPtr->numTags == tagInfoPtr->arraySize)
     {
-      GtkTextTag **newTags;
-      int *newCounts, newSize;
-
-      newSize = 2*tagInfoPtr->arraySize;
-      newTags = (GtkTextTag **) g_malloc ((unsigned)
-                                          (newSize*sizeof (GtkTextTag *)));
-      memcpy ((void *) newTags, (void *) tagInfoPtr->tags,
-              tagInfoPtr->arraySize  *sizeof (GtkTextTag *));
-      g_free ((char *) tagInfoPtr->tags);
-      tagInfoPtr->tags = newTags;
-      newCounts = (int *) g_malloc ((unsigned) (newSize*sizeof (int)));
-      memcpy ((void *) newCounts, (void *) tagInfoPtr->counts,
-              tagInfoPtr->arraySize  *sizeof (int));
-      g_free ((char *) tagInfoPtr->counts);
-      tagInfoPtr->counts = newCounts;
+      int newSize = 2 * tagInfoPtr->arraySize;
+      tagInfoPtr->tags = g_realloc (tagInfoPtr->tags, newSize * sizeof (GtkTextTag *));
+      tagInfoPtr->counts = g_realloc (tagInfoPtr->counts, newSize * sizeof (int));
       tagInfoPtr->arraySize = newSize;
     }